<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客注册页</title>

    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/register.css">

</head>

<body>
<div class="nav">
    <img src="pic/demo/java-logo.png" alt="">
    <span class="blog-title">博客系统</span>
    <div class="space"></div>
    <a class="nav-span" href="blog_login.html">登录</a>
</div>

<div class="container-login">
    <div class="login-dialog">
        <h3>注册</h3>
        <div class="row">
            <span>用户名</span>
            <input type="text" name="username" id="username" placeholder="请输入用户名">
        </div>
        <div class="row">
            <span>密码</span>
            <input type="password" name="password" id="password" placeholder="请输入密码">
        </div>
        <div class="row">
            <span>确认密码</span>
            <input type="password" name="confirmPassword" id="confirmPassword" placeholder="请再次输入密码">
        </div>
        <div class="row">
            <span>github<br>地址</span>
            <input type="url" name="githubAddress" id="githubAddress" placeholder="请输入github地址 (选填)">
        </div>
        <div class="row">
            <button id="submit" onclick="register()">提交</button>
        </div>

    </div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/common.js"></script>
<script>
    function register() {
        $.ajax({
            url: "user/register",
            type: "post",
            data: {
                userName: $("#username").val(),
                password: $("#password").val(),
                confirmPassword: $("#confirmPassword").val(),
                githubAddress: $("#githubAddress").val()
            },
            success: function (result) {
                if (result.code == "SUCCESS") {
                    // 后端判断成功
                    alert(result.data);
                    location.href = "blog_login.html";
                } else {
                    alert(result.errMsg);
                }
            }
        });
    }
</script>
</body>

</html>